<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui">


    <ui:define name="content">

        <h:panelGroup >
            <h:form  >

                <p:focus id="selectFocus" context="gpSelect" />
                <p:focus id="detailFocus" context="gpDetail" />



                <p:panel header="Manage Collecting Centres">
                    <h:panelGrid id ="gpVeda" columns="2" styleClass="alignTop">

                        <h:panelGrid id="gpSelect" columns="1"  >
                            <p:panel >
                                <f:facet name="header" >
                                    <p:outputLabel value="Collecting Centers" />
                                    <p:commandButton id="btnAdd" value="Add New" style="float: right;"  update="gpDetail"
                                                     action="#{collectingCentreController.prepareAdd()}" styleClass="buttons" />

                                </f:facet>
                                <h:panelGrid id="gpSelectText" >
                                    <p:inputText autocomplete="off" id="txtSearch" value="#{collectingCentreController.selectText}" >
                                        <f:ajax execute="txtSearch" render="lstSelect" event="keyup" />
                                    </p:inputText>
                                    <h:selectOneListbox  id="lstSelect"   size="10" value="#{collectingCentreController.current}" style="min-width: 223px">
                                        <f:selectItems  value="#{collectingCentreController.selectedItems}" var="myItem" itemValue="#{myItem}" itemLabel="#{myItem.name}" ></f:selectItems>
                                        <f:ajax render="gpDetail " execute="lstSelect" >
                                        </f:ajax>
                                    </h:selectOneListbox>
                                </h:panelGrid>
                                <h:panelGrid id="gpSelectButtons" columns="1"  >
                                    <p:commandButton id="btnDelete" onclick="if (!confirm('Are you sure you want to delete this record?'))
                                                return false;" action="#{collectingCentreController.delete()}"  value="Delete"  />
                                </h:panelGrid>
                            </p:panel>
                        </h:panelGrid  >

                        <p:panel>
                            <p:panel id="gpDetail" >
                                <f:facet name="header" >
                                    <p:outputLabel value="Details" />
                                    <p:commandButton id="btnSave" value="Save" action="#{collectingCentreController.saveSelected()}" 
                                                     styleClass="buttons" style="float: right;" update="gpVeda" />
                                    <p:defaultCommand target="btnSave"/>
                                </f:facet>
                                <h:panelGrid id="gpDetailText" columns="2">
                                    <h:outputText id="lblName" value="Name"  ></h:outputText>
                                    <p:inputText autocomplete="off" id="txtName" 
                                                 styleClass="longText"
                                                 value="#{collectingCentreController.current.name}"  ></p:inputText>

                                    <h:outputText id="lblChqPrnName" value="Printi Name" ></h:outputText>
                                    <p:inputText autocomplete="off" id="txtChqPrnName" 
                                                 styleClass="longText"
                                                 value="#{collectingCentreController.current.chequePrintingName}"  ></p:inputText>

                                    <h:outputText value="Code" >                                        
                                    </h:outputText>
                                    <p:inputText autocomplete="off"  value="#{collectingCentreController.current.institutionCode}"  >
                                    </p:inputText> 

                                    <h:outputText value="Descreption" >                                        
                                    </h:outputText>
                                    <p:inputTextarea styleClass="longText" value="#{collectingCentreController.current.descreption}"  >
                                    </p:inputTextarea> 

                                    <h:outputText value="Credit Limit" >                                        
                                    </h:outputText>
                                    <p:inputText autocomplete="off"  value="#{collectingCentreController.current.allowedCredit}"  >
                                    </p:inputText>

                                    <h:outputText id="lblPhone" value="Phone" ></h:outputText>
                                    <p:inputText autocomplete="off" id="txtPhone" value="#{collectingCentreController.current.phone}"  ></p:inputText>

                                    <h:outputText id="lblFax" value="Fax" ></h:outputText>
                                    <p:inputText autocomplete="off" id="txtFax" value="#{collectingCentreController.current.fax}"  ></p:inputText>

                                    <h:outputText id="lblEMail" value="Email" ></h:outputText>
                                    <p:inputText autocomplete="off" id="txtEmail" value="#{collectingCentreController.current.email}"  ></p:inputText>

                                    <h:outputText id="lblAdress" value="Address" ></h:outputText>
                                    <p:inputTextarea id="txtAdress" value="#{collectingCentreController.current.address}" styleClass="longText" ></p:inputTextarea>

                                    <h:outputText id="lblWeb" value="Web" ></h:outputText>
                                    <p:inputText autocomplete="off" id="txtWeb" value="#{collectingCentreController.current.web}"  ></p:inputText>

                                    <h:outputText id="lblAcc" value="Account No" ></h:outputText>
                                    <p:inputText autocomplete="off" id="txtAcc" value="#{collectingCentreController.current.accountNo}"  ></p:inputText>

                                    <h:outputText value="Creater" ></h:outputText>
                                    <h:outputText value="#{collectingCentreController.current.creater.webUserPerson.name}" ></h:outputText>
                                    
                                    <h:outputText value="Created At" ></h:outputText>
                                    <h:outputText value="#{collectingCentreController.current.createdAt}" >
                                        <f:convertDateTime pattern="yyyy MM dd hh:mm:ss a" />
                                     </h:outputText>
                                </h:panelGrid>
                            </p:panel>
                        </p:panel>
                    </h:panelGrid>
                </p:panel>
            </h:form>

        </h:panelGroup>

    </ui:define>

</ui:composition>
